//
//  GPMapCell.m
//  GoldPig
//
//  Created by 虎爷 on 2020/1/3.
//  Copyright © 2020 虎爷. All rights reserved.
//

#import "GPMapCell.h"

@interface GPMapCell ()
@property (weak, nonatomic) IBOutlet UIImageView *lvBGImg1;
@property (weak, nonatomic) IBOutlet UIImageView *lvBGImg2;
@property (weak, nonatomic) IBOutlet UIImageView *lvBGImg3;
@property (weak, nonatomic) IBOutlet UIImageView *lvBGImg4;
@property (weak, nonatomic) IBOutlet UIImageView *lvBGImg5;
@property (weak, nonatomic) IBOutlet UIImageView *lvBGImg6;
@property (weak, nonatomic) IBOutlet UIImageView *lvBGImg7;
@property (weak, nonatomic) IBOutlet UIImageView *lvBGImg8;
@property (weak, nonatomic) IBOutlet UILabel *lvLab1;
@property (weak, nonatomic) IBOutlet UILabel *lvLab2;
@property (weak, nonatomic) IBOutlet UILabel *lvLab3;
@property (weak, nonatomic) IBOutlet UILabel *lvLab4;
@property (weak, nonatomic) IBOutlet UILabel *lvLab5;
@property (weak, nonatomic) IBOutlet UILabel *lvLab6;
@property (weak, nonatomic) IBOutlet UILabel *lvLab7;
@property (weak, nonatomic) IBOutlet UILabel *lvLab8;

@property (weak, nonatomic) IBOutlet UILabel *levelUpNumLab1;
@property (weak, nonatomic) IBOutlet UILabel *levelUpNumLab2;
@property (weak, nonatomic) IBOutlet UILabel *levelUpNumLab3;
@property (weak, nonatomic) IBOutlet UILabel *levelUpNumLab4;
@property (weak, nonatomic) IBOutlet UILabel *levelUpNumLab5;
@property (weak, nonatomic) IBOutlet UILabel *levelUpNumLab6;
@property (weak, nonatomic) IBOutlet UILabel *levelUpNumLab7;
@property (weak, nonatomic) IBOutlet UILabel *levelUpNumLab8;

@property (weak, nonatomic) IBOutlet UIView *lvBGView1;
@property (weak, nonatomic) IBOutlet UIView *lvBGView2;
@property (weak, nonatomic) IBOutlet UIView *lvBGView3;
@property (weak, nonatomic) IBOutlet UIView *lvBGView4;
@property (weak, nonatomic) IBOutlet UIView *lvBGView5;
@property (weak, nonatomic) IBOutlet UIView *lvBGView6;
@property (weak, nonatomic) IBOutlet UIView *lvBGView7;
@property (weak, nonatomic) IBOutlet UIView *lvBGView8;

@property (weak, nonatomic) IBOutlet UIImageView *suo1;
@property (weak, nonatomic) IBOutlet UIImageView *suo2;
@property (weak, nonatomic) IBOutlet UIImageView *suo3;
@property (weak, nonatomic) IBOutlet UIImageView *suo4;
@property (weak, nonatomic) IBOutlet UIImageView *suo5;
@property (weak, nonatomic) IBOutlet UIImageView *suo6;
@property (weak, nonatomic) IBOutlet UIImageView *suo7;
@property (weak, nonatomic) IBOutlet UIImageView *suo8;
@end
@implementation GPMapCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}
-(void)setRow:(NSInteger)row{
    _row = row;

    [self setLev:row];
    
    if (row != 0) {

        self.lvLab8.text = [NSString stringWithFormat:@"Lv.%ld",60 - row*8 + 4];
        self.lvLab7.text = [NSString stringWithFormat:@"Lv.%ld",60 - row*8 + 3];
        self.lvLab6.text = [NSString stringWithFormat:@"Lv.%ld",60 - row*8 + 2];
        self.lvLab5.text = [NSString stringWithFormat:@"Lv.%ld",60 - row*8 + 1];
        
        NSDictionary *levDic8 = self.levelArr[60 - row*8 + 3];
        NSDictionary *levDic7 = self.levelArr[60 - row*8 + 2];
        NSDictionary *levDic6 = self.levelArr[60 - row*8 + 1];
        NSDictionary *levDic5 = self.levelArr[60 - row*8 + 0];

        self.levelUpNumLab8.text = [NSString stringWithFormat:@"%@",levDic8[@"levelUpNum"]];
        self.levelUpNumLab7.text = [NSString stringWithFormat:@"%@",levDic7[@"levelUpNum"]];
        self.levelUpNumLab6.text = [NSString stringWithFormat:@"%@",levDic6[@"levelUpNum"]];
        self.levelUpNumLab5.text = [NSString stringWithFormat:@"%@",levDic5[@"levelUpNum"]];
        
    }else{
        [self.suo5 setHidden:YES];
        [self.suo6 setHidden:YES];
        [self.suo7 setHidden:YES];
        [self.suo8 setHidden:YES];
    }
    
    
    self.lvLab4.text = [NSString stringWithFormat:@"Lv.%ld",60 - row*8 - 0];
    self.lvLab3.text = [NSString stringWithFormat:@"Lv.%ld",60 - row*8 - 1];
    self.lvLab2.text = [NSString stringWithFormat:@"Lv.%ld",60 - row*8 - 2];
    self.lvLab1.text = [NSString stringWithFormat:@"Lv.%ld",60 - row*8 - 3];

    NSDictionary *levDic4 = self.levelArr[60 - row*8 - 1];
    NSDictionary *levDic3 = self.levelArr[60 - row*8 - 2];
    NSDictionary *levDic2 = self.levelArr[60 - row*8 - 3];
    NSDictionary *levDic1 = self.levelArr[60 - row*8 - 4];
    self.levelUpNumLab4.text = [NSString stringWithFormat:@"%@",levDic4[@"levelUpNum"]];
    self.levelUpNumLab3.text = [NSString stringWithFormat:@"%@",levDic3[@"levelUpNum"]];
    self.levelUpNumLab2.text = [NSString stringWithFormat:@"%@",levDic2[@"levelUpNum"]];
    self.levelUpNumLab1.text = [NSString stringWithFormat:@"%@",levDic1[@"levelUpNum"]];

    
}

-(void)setLev:(NSInteger)row{

    for (int i = 0; i<8; i++) {
        UIImageView *img = [self viewWithTag:i+10];
        UIView *view = [self viewWithTag:i+20];
        UIImageView *suo = [self viewWithTag:i+30];
        if ((60 - row*8 - 3 + i)  > self.level.intValue) {
            img.image = [UIImage imageNamed:[NSString stringWithFormat:@"p%ld",60 - row*8-3+i]];
            [view setHidden:YES];
            [suo setHidden:NO];
        }else{
            img.image = [UIImage imageNamed:[NSString stringWithFormat:@"%ld",60 - row*8-3+i]];
            [view setHidden:NO];
            [suo setHidden:YES];
        }
    }
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}
+ (instancetype)cellWithTableView:(UITableView *)tableView{
    
    GPMapCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell"];
    if (!cell) {
        cell = NSbunleloadNibName(@"GPMapCell");
    }
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    return cell;
}
@end
